package com.sali.b_design_pattern.g_singleton_pattern.lesson_singleton.a_hungry;

/**
 * @description:
 * @date: 2023/3/19 12:32.
 * @version: 1.0
 */
public class HungryStarter {

    public static void main(String[] args) {
        A_HungrySingleton instance1 = A_HungrySingleton.getInstance();
        A_HungrySingleton instance2 = A_HungrySingleton.getInstance();
        System.out.println(instance1 == instance2);

        // 单例模式应用
        C_ShoppingCartManager cart = C_ShoppingCartManager.getInstance();
        // 获取购物⻋实例并添加商品
        cart.addToCart("apple", 1);
        cart.addToCart("banana", 2);
        // 输出购物⻋内容
        cart.viewCart();
    }

}
